package cn.juque.workflow.service.impl;

import cn.juque.common.base.PageInfo;
import cn.juque.workflow.entity.LeaveInfo;
import cn.juque.workflow.mapper.LeaveInfoMapper;
import cn.juque.workflow.service.ILeaveInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author JUQUE
 * @version 1.0.0
 * <ul>
 *  <li>simple-generator</li>
 *  <li>请假申请单信息</li>
 * </ul>
 * @date 2023-01-31 16:31:27
 **/
@Service("leaveInfoService")
public class LeaveInfoServiceImpl implements ILeaveInfoService {

    @Resource
    private LeaveInfoMapper leaveInfoMapper;

    /**
     * 分页查询
     *
     * @param pageInfo  pageInfo
     * @param leaveInfo leaveInfo
     * @return DataGrid
     */
    @Override
    public List<LeaveInfo> listInfoWithPage(PageInfo pageInfo, LeaveInfo leaveInfo) {
        Page<LeaveInfo> page = new Page<>(pageInfo.getPage(), pageInfo.getLimit());
        List<LeaveInfo> list = this.leaveInfoMapper.queryInfoList(page, leaveInfo);
        pageInfo.setTotal(page.getTotal());
        return list;
    }

    /**
     * 查询
     *
     * @param leaveInfo leaveInfo
     * @return List
     */
    @Override
    public List<LeaveInfo> listInfoWithoutPage(LeaveInfo leaveInfo) {
        return this.leaveInfoMapper.queryInfoList(leaveInfo);
    }

    /**
     * 详情
     *
     * @param id 主键
     * @return LeaveInfo
     */
    @Override
    public LeaveInfo detail(String id) {
        return this.leaveInfoMapper.selectById(id);
    }
}
